package com.swj.modules.monitor.vo.server;

import com.swj.common.core.utils.BigDecimalUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//內存相关信息
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Memory {

    //内存总量
    private double total;

    //已用内存
    private double used;

    //剩余内存
    private double free;

    public double getTotal(){
        return BigDecimalUtil.div(total, (1024 * 1024 * 1024), 2);
    }

    public double getUsed() {
        return BigDecimalUtil.div(used, (1024 * 1024 * 1024), 2);
    }

    public double getFree() {
        return BigDecimalUtil.div(free, (1024 * 1024 * 1024), 2);
    }

    public double getUsage() {
        return BigDecimalUtil.mul(BigDecimalUtil.div(used, total, 4), 100);
    }
}
